/**
 * Huisou.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */

package com.chenzehe.zdmya.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chenzehe.zdmya.dao.MallDao;
import com.chenzehe.zdmya.domain.Mall;

/**
 * @description
 * 
 * @author chenzehe
 * @email hljuczh@163.com
 * @create 2012-8-14 下午09:00:35
 */
@Service
@Transactional
public class MallService extends BaseService implements IMallService {
	@Resource
	MallDao mallDao;

	@Override
	public Mall getMallByEname(String ename) {
		Mall mall = mallDao.findUniqueBy("ename", ename);
		return mall;
	}

	@Override
	public Mall getMallById(int id) {
		Mall mall = mallDao.get(id);
		return mall;
	}

	@Override
	public String getGoUrl(String ename) {
		String hql = "SELECT new Mall(goUrl) FROM Mall WHERE ename=?";
		List<Mall> listMall = mallDao.find(hql, ename);
		if (listMall != null && listMall.size() > 0) {
			return listMall.get(0).getGoUrl();
		}
		return "/";
	}
}
